﻿@using eCollabro.Client.Models.Content;
@using eCollabro.Client.Models.Core;
@using eCollabro.Web.Base;
@using eCollabro.Common;
@model ContentPageCategoryModel
@{
    List<PermissionEnum> userPermissions = (List<PermissionEnum>)ViewBag.UserPermissions;
    bool canEdit = userPermissions.Contains(PermissionEnum.EditContent);
    bool canDelete = userPermissions.Contains(PermissionEnum.DeleteContent);
    bool canAdd = userPermissions.Contains(PermissionEnum.AddContent);
    List<PageButton> pageButtons = new List<PageButton>();
    pageButtons.Add(new PageButton { Id = "btnRefresh", CssClass="btn btn-warning", ButtonText = "Refresh", Icon = "refresh", Method = "loadContentPages(" + Model.ContentPageCategoryId + ")" });
    pageButtons.Add(new PageButton { Id = "btnContentPageCategories", CssClass="btn btn-success", ButtonText = "Categories", Icon = "th-list", Method = "contentPageCategories()" });
    if (canAdd)
    {
        pageButtons.Add(new PageButton { Id = "btnAdd", ButtonText = "Add Page", Icon = "plus", Method = "openContentPage(0," + Model.ContentPageCategoryId + ")" });
    }
}
@Scripts.Render("~/bundles/contentpage")
<div id="placeHolderContentPages"></div>
<div id="divContentPages" ng-controller="contentPagesController" ng-init="initialize(@Model.ContentPageCategoryId,'@canAdd','@canEdit','@canDelete')">
    @Html.Partial("_PageHeader", new PageHeaderModel { ViewId = "ContentPages", PageTitle = "Content Pages - {{contentPageCategory.ContentPageCategoryName}}", PageButtons = pageButtons })
    <table style="width:100%" class="table table-striped table-bordered" id="tblContentPages" cellspacing="0">
        <thead>
            <tr>
                @if (canAdd || canEdit || canDelete) // Contributor
                {
                    <th>Id #</th>
                    <th style="width:400px">Title</th>
                    <th>Active</th>
                    <th>Approved</th>
                    <th>Action</th>
                }
                else
                {
                    <th>Title</th>
                }
            </tr>
        </thead>
    </table>
</div>



